﻿using System;

namespace newBlog.CenterInc.Ctrltor
{
    public class Upload_inc
    {
        string[] updata_image = { "image/jpeg", "image/jpg", "image/png" };
        string[] updata_article = { "image/gif", "image/webp" };
        //控制上传的头像大小
        public string portrait(int filesize, string MiMEname)
        {

            if (filesize == 0 || filesize == null)
            {
                return "文件不能为空";
            }

            if (filesize > 1024 * 1024)
            { //限制大小为50kb

                return "上传文件太大了";
            }

            if (Array.IndexOf(updata_image, MiMEname) == -1)
            {
                return "上传的文件格式不是png，jpg/jpeg格式";
            }
            return null;
        }
        public string article(int filesize, string MiMEname)
        {
            if (filesize == 0 || filesize == null)
            {
                return "文件不能为空";
            }

            if (filesize > 1024 * 1024 * 2)
            { //限制大小为2m

                return "上传文件太大了";
            }

            if (Array.IndexOf(updata_image, MiMEname) == -1)
            {
                return "上传的文件格式不是图片...";
            }
            return null;
        }

        
    }
}